﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// Copyright (C) Christoph van der Fecht - VDsoft - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited,
// unless it is communicated and authorized by the copyright owner.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using TVDB.Model;

namespace SeriesManager.Model
{
	/// <summary>
	/// ToDo: Update docu.
	/// </summary>
	public class Banner : INotifyPropertyChanged
	{
		/// <summary>
		/// The Id.
		/// </summary>
		private int id = 0;

		/// <summary>
		/// The BannerPath.
		/// </summary>
		private string bannerPath = null;

		/// <summary>
		/// The Typ.
		/// </summary>
		private BannerTyp typ;

		/// <summary>
		/// The ThumbnailPath.
		/// </summary>
		private string thumbnailPath = null;

		/// <summary>
		/// The SeasonsNumber.
		/// </summary>
		private int seasonNumber = 0;

		/// <summary>
		/// Initializes a new instance of the <see cref="Banner"/> class.
		/// </summary>
		public Banner()
		{
		}

		/// <summary>
		/// Occurs when a property changed its value.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		/// <summary>
		/// Gets or sets the Id.
		/// </summary>
		public int Id
		{
			get
			{
				return this.id;
			}

			set
			{
				if (value == this.id)
				{
					return;
				}

				this.id = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the BannerPath.
		/// </summary>
		public string BannerPath
		{
			get
			{
				return this.bannerPath;
			}

			set
			{
				if (value == this.bannerPath)
				{
					return;
				}

				this.bannerPath = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Typ.
		/// </summary>
		public BannerTyp Typ
		{
			get
			{
				return this.typ;
			}

			set
			{
				if (value == this.typ)
				{
					return;
				}

				this.typ = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the ThumbnailPath.
		/// </summary>
		public string ThumbnailPath
		{
			get
			{
				return this.thumbnailPath;
			}

			set
			{
				if (value == this.thumbnailPath)
				{
					return;
				}

				this.thumbnailPath = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the SeasonsNumber.
		/// </summary>
		public int SeasonsNumber
		{
			get
			{
				return this.seasonNumber;
			}

			set
			{
				if (value == this.seasonNumber)
				{
					return;
				}

				this.seasonNumber = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Converts a <see cref="TVDB.Model.Banne"/> object into a <see cref="Banner"/> object.
		/// </summary>
		/// <param name="toConvert">Banner to convert.</param>
		/// <returns><see cref="Banner"/> object with all details.</returns>
		public static explicit operator Banner(TVDB.Model.Banner toConvert)
		{
			Banner converted = new Banner
			{
				Id = toConvert.Id,
				BannerPath = toConvert.BannerPath,
				Typ = toConvert.Type,
				ThumbnailPath = toConvert.ThumbnailPath,
				SeasonsNumber = toConvert.Season
			};

			return converted;
		}

		/// <summary>
		/// Raises the <see cref="PropertyChanged"/> event.
		/// </summary>
		/// <param name="propertyName">Name of the property that changed its value.</param>
		private void RaisePropertyChanged([CallerMemberName]string propertyName = "")
		{
			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
